﻿using DomainExample.Extensions;

namespace DomainExample.DomainModel.PersonModel
{
    public sealed class Person : IEntity
    {
        public PersonId Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }

        private Person()
        {
            
        }

        public static Person NewPerson()
        {
            return NewPerson(PersonId.NewPersonId());
        }

        public static Person NewPerson(PersonId personId)
        {
            return new Person { Id = personId };
        }

        public bool IsValidForPersistence()
        {
            return
                !FirstName.IsNullOrWhitespace()
                && !LastName.IsNullOrWhitespace();
        }

        public override string ToString()
        {
            return string.Format(
                "{0}: Id={1}, FirstName={2}, LastName={3}",
                base.ToString(),
                Id,
                FirstName,
                LastName
                );
        }
    }
}
